package service;

import dao.UserDao;
import entity.User;

public class UserService {

    private UserDao userDao;

    public UserService() {
        userDao = new UserDao();
    }

    public User login(String username, String password, int userType) {
        User user = userDao.getUserByUsernameAndUserType(username, userType);
        System.out.println("user"+user.getUserId());
        if (user != null && user.getPassword().equals(password)) {
            return user;
        }
        return null;
    }

    public boolean register(User user) {
        return userDao.addUser(user);
    }
}
